﻿/*
*
*              Ckeditor的配置文件
*/

CKEDITOR.editorConfig = function (config) {
    config.language = 'zh-cn.js';
    config.uiColor = '#AADC6E';
    config.skin = 'v2';
    config.font_names = '宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;' + config.font_names;
    config.toolbar = 'Full';
    config.toolbar_Full = [
       ['Source', 'cmspager', 'Preview', 'Templates', 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord',
        'Find', 'Replace', 'SelectAll', 'RemoveFormat', 'Bold', 'Italic', 'Underline', 'Strike', 'NumberedList',
        'BulletedList', 'Outdent', 'Indent', 'Blockquote', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock',
        'Link', 'Unlink', '-', 'Image', 'MultilFileUpLoad', 'Table', 'HorizontalRule', 'Styles', 'Format', 'Font', 'FontSize', 'TextColor']
    ];
    /*
    config.toolbar_AllBar =
    [
    { name: 'document', items: ['Source', '-', 'Save', 'NewPage', 'DocProps', 'Preview', 'Print', '-', 'Templates'] },
    { name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
    { name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt'] },
    { name: 'forms', items: ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'] },
    '/',
    { name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] },
    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl'] },
    { name: 'links', items: ['Link', 'Unlink', 'Anchor'] },
    { name: 'insert', items: ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe'] },
    '/',
    { name: 'styles', items: ['Styles', 'Format', 'Font', 'FontSize'] },
    { name: 'colors', items: ['TextColor', 'BGColor'] },
    { name: 'tools', items: ['Maximize', 'ShowBlocks', '-', 'About'] }
    ];
    */
    //config.enterMode = CKEDITOR.ENTER_BR; //回车br
    config.toolbarCanCollapse = true;     //工具栏是否可以被收缩
    config.protectedSource.push(/<style[\s\S]*?\<\/style>/g);
    var ckfinderPath = "/js"; //ckfinder路径
    config.filebrowserBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html';
    config.filebrowserImageBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html?type=Images';
    config.filebrowserFlashBrowseUrl = ckfinderPath + '/ckfinder/ckfinder.html?type=Flash';
    config.filebrowserUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files';
    config.filebrowserImageUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images';
    config.filebrowserFlashUploadUrl = ckfinderPath + '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash';

    //是否强制用“&”来代替“&amp;”plugins/htmldataprocessor/plugin.js
    config.forceSimpleAmpersand = false;
    config.entities = false;

    //是否转换一些难以显示的字符为相应的HTML字符
    //config.entities_greek = false;
    //是否开启 图片和表格 的改变大小的功能
    //config.disableObjectResizing = true

    FormatOutput = false;   //当输出内容时是否自动格式化代码
    FormatSource = false;   //在切换到代码视图时是否自动格式化代码 
    config.extraPlugins = "cmspager,MultilFileUpLoad";

    CKEDITOR.on('instanceReady', function (ev) {
        with (ev.editor.dataProcessor.writer) {
            setRules("p", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("h1", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("h2", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("h3", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("h4", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("h5", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("div", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("table", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("tr", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("td", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("iframe", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("li", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("ul", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
            setRules("ol", { indent: false, breakAfterOpen: false, breakBeforeClose: false });
        }
    });
};
